<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>链接工具</title>
		<link href="../../../static/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="../../../static/css/offerChainTool.css">
	</head>

	<body>
		<div class="container-fluid backContainer" style="padding-left: 20px;">
			<h3>文案智能转链</h3>

			<form class="form-horizontal">
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-1 control-label"><span class="inputRequired">*</span>京东联盟ID</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="jdtext" placeholder="京东联盟ID">
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-1 control-label">推广位ID</label>
					<div class="col-sm-4">
						<input type="text" class="form-control" id="protext" placeholder="推广位ID（不填取默认值）">
					</div>
				</div>
				<div class="form-group">
					<label for="inputPassword3" class="col-sm-1 control-label"><span class="inputRequired">*</span>输入转链内容</label>
					<div class="col-sm-5">
						<textarea class="form-control" rows="8" id="teamtext" placeholder="==============样例================&#13;&#10;【京东双11日零点蹲守抢券汇总】&#13;&#10;http://url.cn/*&#13;&#10;京东双11主会场 领全品类券和支付券 &#13;&#10;http://url.cn//* &#13;&#10;京东双11活动攻略安排预告 &#13;&#10;http://url.cn//* &#13;&#10;......"></textarea>
					</div>
				</div>
				<div class="form-group an" style="margin: 0!important;">
					<div class="col-sm-offset-1 col-sm-1">
						<button type="button" class="btn btn-default ddt-btn from-btn red" id="submitBut" data-toggle="modal" data-target="#myModal" style="width: 100%;margin: 0 !important;">转链</button>
					</div>
					<div class="col-sm-1" style="position: relative;top: 0;left: -10px;">
						<button type="button" class="btn btn-default ddt-btn-fan from-btn" id="removeBut" style="width: 100%;margin: 0 !important;">清空</button>
					</div>
				</div>
			</form>
			
			<!-- Modal -->
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" >
			  <div class="modal-dialog" role="document">
			    <div class="modal-content" style="padding: 0px 5%;">
			      <div class="modal-header" style="padding-top: 30px;">
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			        <h4 class="modal-title result" id="myModalLabel"><strong>转链结果</strong></h4>
			      </div>
			      <div class="modal-body">
			        <div class="row" id="chainmain">
			        	<div class="col-sm-12" >
			        		<img  src="../../../static/images/tupian.png" width="40%" class="img-responsive" id="maskimg"/>
			        	</div>
			        	<div class="col-sm-12 back_chainTool_model cop_p" id="copycon" style="margin-top: 2%;">
			        		<!--<p>==============样例================</p>
							<p>【京东双11日零点蹲守抢券汇总】</p>
							<p>http://url.cn/*</p>
							<p>京东双11主会场 领全品类券和支付券</p> 
							<p>http://url.cn//*</p>
							<p>京东双11活动攻略安排预告</p>
							<p>http://url.cn//*</p>
							<p>......</p>-->
			        	</div>
			        </div>
			      </div>
			      <div class="modal-footer">
			      	<button type="button" class="btn btn-default ddt-btn-fan from-btn cancel" id="submitBut" data-dismiss="modal" style="width: 10%;margin: 0;padding: 3px 0;font-size: 14px;">取消</button>
			      	<button type="button" class="btn btn-default ddt-btn from-btn copy" data-clipboard-action="copy" data-clipboard-target="#copycon"  id="rescopyBut" style="width: 10%;margin: 0;padding: 3px 0;font-size: 14px" >复制</button>
			      </div>
			    </div>
			  </div>
			</div>

		</div>
		<script src="../../../static/js/jquery.js" type="text/javascript"></script>
		<script src="../../../static/js/clipboard.min.js" type="text/javascript"></script>
		<script src="../../../static/js/config.js" type="text/javascript"></script>
		<script src="../../../static/js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" src="../../../static/bootstrap-3.3.7/js/bootstrap.min.js"></script>
		<script>
			$(function(){
				var href = window.location.href;
//				var id = href.split('?')[1].split('=')[1];
				var id = href.split('id=')[1];
				var id = localStorage.getItem('id');
				var token = localStorage.getItem('token');
				//用户回显联盟id和推广位id
				$.ajax({
					url:C.interface.peronalInter,
					type:'get',
					dataType:'json',
					data:{id:id,token:token,appId:'gzh'},
					success:function(data){
//						console.log(data);
						if(data.code == "10000"){
							var json = data.data;
							$("#jdtext").val(json.jdlmId);
							$("#protext").val(json.positionId);
						}
					}
				})	
				//转链工具内容
				
				$.ajax({
					url:C.interface.erYinter,
					type:'get',
					dataType:'json',
					data:{id:id,token:token,appId:'gzh'},
					success:function(data){
//						console.log(data)
						if(data.code == "10000"){
//							console.log(data.data);
							var json = data.data;
							var html = '<p>'+json.name+'</p>'
									   +'<p>友惠价'+json.conPrice+'</p>'
									   +'<p>原价'+json.price+'</p>'
									   +'<p>'+json.url+'</p>'
							$("#copycon").html(html);		   
									   
							$("#teamtext").val(json.name+','+json.url);
							$("#maskimg").attr('src',json.image);
							var clipboard = new Clipboard('#rescopyBut');
						    clipboard.on('success', function(e) {
//						        console.log(e);
						    });
						
						    clipboard.on('error', function(e) {
//						        console.log(e);
						    });
						}else{
							$("#teamtext").val(data.msg);
							$("#copycon").html(data.msg)
						}
					}
				})
				//清空数据
				$("#removeBut").click(function(){
					
					$("#teamtext").val('')
				})
//				console.log(id);
			})
		</script>
	</body>

</html>